package com.wzy.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 * 查询当前用户的任务列表
 */
public class ActivitiTaskQuery {
    public static void main(String[] args) {
        //得到processEngine对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();

        //2.得到TaskService对象
        TaskService taskService = defaultProcessEngine.getTaskService();

        //3.查询当前用户的的任务
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("myProcess_1")
                .taskAssignee("王五")
                .singleResult();

        taskService.complete(task.getId());

        //3.根据流程定义的key,负责人assignee来实现当前用户的任务列表查询;

//        Task task = taskService.createTaskQuery()
//                .processDefinitionKey("myProcess_1")
//                .taskAssignee("王五")
//                .singleResult();
        //4.展示
        System.out.println("流程实例ID:" + task.getProcessInstanceId());
        System.out.println("任务的ID:" + task.getId());
        System.out.println("任务负责人:" + task.getAssignee());
        System.out.println("任务名称" + task.getName());


        //.张三任务列表的查询
    }

}
